<template>
  <div class="page_search">
	<div class="warp">
	  <div class="container">
		<div class="row">
		  <div class="col-12">
			<div class="card_result_search">
			  <div class="title">搜索结果</div>
				<!-- 商品搜索结果 -->
			  <list_result_search
				:list="result_goods"
				title="宠物商店"
				source_table="goods"
			  ></list_result_search>
				<!-- 文章搜索结果 -->
			  <list_result_search
				:list="result_article"
				title="宠物资讯"
				source_table="article"
			  ></list_result_search>
				<!-- 论坛搜索结果 -->
			  <list_result_search
				:list="result_forum"
				title="宠物论坛"
				source_table="forum"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/pet_adoption/list', 'get')"
				:list="result_pet_adoption_pet_name"
				title="宠物领养宠物名称"
				source_table="pet_adoption"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/pet_adoption/list', 'get')"
				:list="result_pet_adoption_pet_type"
				title="宠物领养宠物类型"
				source_table="pet_adoption"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/ordinary_users/list', 'get')"
				:list="result_ordinary_users_user_name"
				title="普通用户用户姓名"
				source_table="ordinary_users"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/logistics_information/list', 'get')"
				:list="result_logistics_information_order_number"
				title="物流信息订单编号"
				source_table="logistics_information"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/return_information/list', 'get')"
				:list="result_return_information_order_number"
				title="退货信息订单编号"
				source_table="return_information"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/adoption_information/list', 'get')"
				:list="result_adoption_information_pet_name"
				title="领养信息宠物名称"
				source_table="adoption_information"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/adoption_information/list', 'get')"
				:list="result_adoption_information_pet_type"
				title="领养信息宠物类型"
				source_table="adoption_information"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/pet_foster_care/list', 'get')"
				:list="result_pet_foster_care_pet_name"
				title="宠物寄养宠物名称"
				source_table="pet_foster_care"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/pet_foster_care/list', 'get')"
				:list="result_pet_foster_care_pet_type"
				title="宠物寄养宠物类型"
				source_table="pet_foster_care"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/pet_loss_report/list', 'get')"
				:list="result_pet_loss_report_pet_name"
				title="宠物挂失宠物名称"
				source_table="pet_loss_report"
			  ></list_result_search>
			  <list_result_search
				v-if="$check_action('/pet_loss_report/list', 'get')"
				:list="result_pet_loss_report_pet_type"
				title="宠物挂失宠物类型"
				source_table="pet_loss_report"
			  ></list_result_search>
			</div>
		  </div>
		</div>
	  </div>
	</div>
  </div>
</template>

<script>
import mixin from "../../mixins/page.js";
import list_result_search from "../../components/diy/list_result_search.vue";

export default {
  mixins: [mixin],
  data() {
	return {
	  "query": {
		word: "",
	  },
	  "result_goods": [],
	  "result_article": [],
	  "result_forum": [],
			"result_pet_adoption_pet_name":[],
			"result_pet_adoption_pet_type":[],
			"result_ordinary_users_user_name":[],
			"result_logistics_information_order_number":[],
			"result_return_information_order_number":[],
			"result_adoption_information_pet_name":[],
			"result_adoption_information_pet_type":[],
			"result_pet_foster_care_pet_name":[],
			"result_pet_foster_care_pet_type":[],
			"result_pet_loss_report_pet_name":[],
			"result_pet_loss_report_pet_type":[],
	};
  },
  methods: {
	/**
	 * 获取宠物商店
	 */
	get_goods() {
	  this.$get("~/api/goods/get_list?like=0", { page: 1, size: 10, title: this.query.word }, (json) => {
		if (json.result) {
		  this.result_goods = json.result.list;
		}
	  });
	},
	/**
	 * 获取文章
	 */
	get_article() {
	  this.$get("~/api/article/get_list?like=0", { page: 1, size: 10, title: this.query.word }, (json) => {
		if (json.result) {
		  this.result_article = json.result.list;
		}
	  });
	},
	/**
	 * 获取宠物论坛
	 */
	get_forum() {
	  this.$get("~/api/forum/get_list?like=0", { page: 1, size: 10, title: this.query.word }, (json) => {
		if (json.result) {
		  this.result_forum = json.result.list;
		}
	  });
	},
	/**
	 * 获取pet_name
	 */
	get_pet_adoption_pet_name(){
		this.$get("~/api/pet_adoption/get_list?like=0", { page: 1, size: 10, "pet_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_pet_adoption_pet_name = json.result.list;
			result_pet_adoption_pet_name.map(o => o.title = o['pet_name'])
	  			this.result_pet_adoption_pet_name = result_pet_adoption_pet_name
		 	}
		});
	},
	/**
	 * 获取pet_type
	 */
	get_pet_adoption_pet_type(){
		this.$get("~/api/pet_adoption/get_list?like=0", { page: 1, size: 10, "pet_type": this.query.word }, (json) => {
		  if (json.result) {
			var result_pet_adoption_pet_type = json.result.list;
			result_pet_adoption_pet_type.map(o => o.title = o['pet_type'])
	  			this.result_pet_adoption_pet_type = result_pet_adoption_pet_type
		 	}
		});
	},
	/**
	 * 获取user_name
	 */
	get_ordinary_users_user_name(){
		this.$get("~/api/ordinary_users/get_list?like=0", { page: 1, size: 10, "user_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_ordinary_users_user_name = json.result.list;
			result_ordinary_users_user_name.map(o => o.title = o['user_name'])
	  			this.result_ordinary_users_user_name = result_ordinary_users_user_name
		 	}
		});
	},
	/**
	 * 获取order_number
	 */
	get_logistics_information_order_number(){
		this.$get("~/api/logistics_information/get_list?like=0", { page: 1, size: 10, "order_number": this.query.word }, (json) => {
		  if (json.result) {
			var result_logistics_information_order_number = json.result.list;
			result_logistics_information_order_number.map(o => o.title = o['order_number'])
	  			this.result_logistics_information_order_number = result_logistics_information_order_number
		 	}
		});
	},
	/**
	 * 获取order_number
	 */
	get_return_information_order_number(){
		this.$get("~/api/return_information/get_list?like=0", { page: 1, size: 10, "order_number": this.query.word }, (json) => {
		  if (json.result) {
			var result_return_information_order_number = json.result.list;
			result_return_information_order_number.map(o => o.title = o['order_number'])
	  			this.result_return_information_order_number = result_return_information_order_number
		 	}
		});
	},
	/**
	 * 获取pet_name
	 */
	get_adoption_information_pet_name(){
		this.$get("~/api/adoption_information/get_list?like=0", { page: 1, size: 10, "pet_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_adoption_information_pet_name = json.result.list;
			result_adoption_information_pet_name.map(o => o.title = o['pet_name'])
	  			this.result_adoption_information_pet_name = result_adoption_information_pet_name
		 	}
		});
	},
	/**
	 * 获取pet_type
	 */
	get_adoption_information_pet_type(){
		this.$get("~/api/adoption_information/get_list?like=0", { page: 1, size: 10, "pet_type": this.query.word }, (json) => {
		  if (json.result) {
			var result_adoption_information_pet_type = json.result.list;
			result_adoption_information_pet_type.map(o => o.title = o['pet_type'])
	  			this.result_adoption_information_pet_type = result_adoption_information_pet_type
		 	}
		});
	},
	/**
	 * 获取pet_name
	 */
	get_pet_foster_care_pet_name(){
		this.$get("~/api/pet_foster_care/get_list?like=0", { page: 1, size: 10, "pet_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_pet_foster_care_pet_name = json.result.list;
			result_pet_foster_care_pet_name.map(o => o.title = o['pet_name'])
	  			this.result_pet_foster_care_pet_name = result_pet_foster_care_pet_name
		 	}
		});
	},
	/**
	 * 获取pet_type
	 */
	get_pet_foster_care_pet_type(){
		this.$get("~/api/pet_foster_care/get_list?like=0", { page: 1, size: 10, "pet_type": this.query.word }, (json) => {
		  if (json.result) {
			var result_pet_foster_care_pet_type = json.result.list;
			result_pet_foster_care_pet_type.map(o => o.title = o['pet_type'])
	  			this.result_pet_foster_care_pet_type = result_pet_foster_care_pet_type
		 	}
		});
	},
	/**
	 * 获取pet_name
	 */
	get_pet_loss_report_pet_name(){
		this.$get("~/api/pet_loss_report/get_list?like=0", { page: 1, size: 10, "pet_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_pet_loss_report_pet_name = json.result.list;
			result_pet_loss_report_pet_name.map(o => o.title = o['pet_name'])
	  			this.result_pet_loss_report_pet_name = result_pet_loss_report_pet_name
		 	}
		});
	},
	/**
	 * 获取pet_type
	 */
	get_pet_loss_report_pet_type(){
		this.$get("~/api/pet_loss_report/get_list?like=0", { page: 1, size: 10, "pet_type": this.query.word }, (json) => {
		  if (json.result) {
			var result_pet_loss_report_pet_type = json.result.list;
			result_pet_loss_report_pet_type.map(o => o.title = o['pet_type'])
	  			this.result_pet_loss_report_pet_type = result_pet_loss_report_pet_type
		 	}
		});
	},

  },
  components: { list_result_search },
	created(){
    this.query.word = this.$route.query.word || "";
  },
  mounted() {
	this.get_goods();
	this.get_article();
	this.get_forum();
		this.get_pet_adoption_pet_name();
		this.get_pet_adoption_pet_type();
		this.get_ordinary_users_user_name();
		this.get_logistics_information_order_number();
		this.get_return_information_order_number();
		this.get_adoption_information_pet_name();
		this.get_adoption_information_pet_type();
		this.get_pet_foster_care_pet_name();
		this.get_pet_foster_care_pet_type();
		this.get_pet_loss_report_pet_name();
		this.get_pet_loss_report_pet_type();
  },
  watch: {
	$route() {
	  $.push(this.query, this.$route.query);
	  this.get_goods();
	  this.get_article();
	  this.get_forum();
	  this.get_pet_adoption_pet_name();
	  this.get_pet_adoption_pet_type();
	  this.get_ordinary_users_user_name();
	  this.get_logistics_information_order_number();
	  this.get_return_information_order_number();
	  this.get_adoption_information_pet_name();
	  this.get_adoption_information_pet_type();
	  this.get_pet_foster_care_pet_name();
	  this.get_pet_foster_care_pet_type();
	  this.get_pet_loss_report_pet_name();
	  this.get_pet_loss_report_pet_type();
	},
  },
};
</script>

<style scoped>
.card_search {
  text-align: center;
}
.card_result_search>.title {
  text-align: center;
  padding: 10px 0;
}
</style>
